#include "zasm.h"


const char *srcFilePath;


char* read_src_file(const char *srcFile);


int zasm_set_args(int argc, const char *argv[])
{
	if (argc < 2)
        return 0;

	printf("Zasm:\t%s\n", argv[0]);
	printf("Src:\t%s\n",  argv[1]);

	srcFilePath = argv[1];

	return 1;
}

void zasm_compile(void)
{
	char *srcBuffer = read_src_file(srcFilePath);
    scanner(srcBuffer);
    free(srcBuffer);
}

char* read_src_file(const char *srcFile)
{
	FILE *f;
	int size;
	register char *buff;
	register int i;

	f = fopen(srcFile, "r");
	fseek(f, 0, SEEK_END);
	size = ftell(f);
	fseek(f, 0, SEEK_SET);

	buff = (char*)malloc(size);

	i = 0;
	while (!feof(f))
		buff[i++] = (char)fgetc(f);

	fclose(f);

	return buff;
}
